<template>
  <div class="right-chart-1">
    <div class="rc1-chart-container">
      <div id="san">
      </div>
    </div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
import axios from 'axios'
export default {
  name: 'RightChart1',
  data () {
    return {
    }
  },
  mounted () {
    this.getCharts()
  },
  methods: {
    async getCharts () {
      const chartDom = document.getElementById('san')
      const myChart = echarts.init(chartDom)
      myChart.hideLoading()
      const temp = await axios.get('https://cdn.jsdelivr.net/gh/apache/echarts-website@asf-site/examples/data/asset/data/masterPainterColorChoice.json')
      const json = temp.data
      const data = json[0].x.map(function (x, idx) {
        return [+x, +json[0].y[idx]]
      })
      const option = {
        title: {
          text: '宣传费财务审批触发情况',
          left: 'right',
          textStyle: {
            color: '#fff'
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow' // 'shadow' as default; can also be 'line' or 'shadow'
          }
        },
        xAxis: {
          type: 'value',
          // splitLine: {
          //   show: false
          // },
          scale: true,
          splitNumber: 5,
          max: 'dataMax',
          axisLabel: {
            formatter: function (val) {
              return val + 's'
            }
          },
          axisLine: {
            lineStyle: {
              color: '#fff'
            }
          }
        },
        yAxis: {
          type: 'value',
          min: 0,
          max: 360,
          interval: 60,
          name: 'Hue',
          // splitLine: {
          //   show: false
          // },
          axisLine: {
            lineStyle: {
              color: '#fff'
            }
          }
        },
        series: [
          {
            name: 'scatter',
            type: 'scatter',
            symbolSize: function (val, param) {
              return (
                json[0].marker.size[param.dataIndex] / json[0].marker.sizeref
              )
            },
            itemStyle: {
              color: function (param) {
                return json[0].marker.color[param.dataIndex]
              }
            },
            data
          }
        ]
      }
      myChart.setOption(option)
    }
  }
}
</script>

<style lang="less">
#san{
  width: 100%;
  height: 100%;
}
.right-chart-1 {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;

  .rc1-header {
    font-size: 24px;
    font-weight: bold;
    height: 30px;
    line-height: 30px;
  }

  .rc1-chart-container {
    flex: 1;
    display: flex;
  }

  .left {
    width: 30%;
    font-size: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    .number {
      font-size: 34px;
      color: #096dd9;
      font-weight: bold;
      margin-bottom: 30px;
    }
  }

  .right {
    flex: 1;
    padding-bottom: 20px;
    padding-right: 20px;
    box-sizing: border-box;
  }
}
</style>
